#ifndef XGDRAW_H
#define XGDRAW_H

#include <headers.h>

const double pi = 3.141592653;

// 定义一些材质颜色
const static GLfloat red_color[] = {1.0f, 0.0f, 0.0f, 1.0f};
const static GLfloat green_color[] = {0.0f, 1.0f, 0.0f, 0.3333f};
const static GLfloat blue_color[] = {0.0f, 0.0f, 1.0f, 0.5f};

class Line{
public:
    double x1,y1,x2,y2;
    QColor color;
    Line();
    Line(double x,double y,double xx,double yy, QColor c);
};

//绘图部件
class xgDraw : public QGLWidget
{
    Q_OBJECT
    public:
        bool fullscreen, mouse_down ;
        QVector<Line> lines;
        //int width, height;

        xgDraw( QWidget* parent = 0);
        ~xgDraw();
        void initializeGL();
        void addline(double x1,double y1,double x2, double y2, QColor c);
        void setColor(QColor c);
    protected:
        //用来保存窗口是否处于全屏状态的变量。
        void paintGL();
        void resizeGL( int width, int height );
        void keyPressEvent( QKeyEvent *e );
        void mouseMoveEvent(QMouseEvent * event );
        void mousePressEvent(QMouseEvent * event );
        void mouseReleaseEvent(QMouseEvent * event);
        void wheelEvent(QWheelEvent * event );
};
#endif // XGDRAW_H
